feat(codegen/golang): add an option to wrap query errors that includes query name#3876
feat(codegen/golang): add an option to wrap query errors that includes query name#3876kyleconroy merged 4 commits intomainfrom
Conversation
|
I'd change the error message to be shorter. Here's the error message from os.ReadFile if a file doesn't exist so I'd change the error message to something like I also know that no matter what format we choose, people will want to change it. |
Yeah, I'd be okay not wrapping errors from those functions simply because they have a larger surface area |
|
Re error messages, agree people will want to change it and we should go as short as possible. I was mimicking what we do in fmt.Errorf("error preparing query {{.MethodName}}: %w", err)and fmt.Errorf("error closing {{.FieldName}}: %w", cerr)arguably those could be shorter as well though. |
|
Let me know if you think we need more tests, e.g. for configurations that branch in the templates in ways I might have missed. |
…s query name (sqlc-dev#3876) * feat(codegen/golang): add an option to wrap query errors that includes query name * use queryretval template func to avoid rewriting test output * shorter error messages * add more tests
This is an attempt to add wrapped errors to query functions in order to get the query name, as described in #1612.
If this approach looks reasonable I'll add more tests. But I'll also have to decide whether to wrap errors coming from the more esoteric function types like batch and copyfrom.